A subnetwork, or subnet, is a logically separate, distinctly addressed part of a single Internet Protocol (IP) network.[1][2] The process of subnetting is the division of a computer network into groups of computers that have the identical common component of their IP address designated as their routing prefix.
Subnetting breaks a network into smaller realms that may use address space more efficiently, or that may be administratively controlled by different entities in the larger organization. Physical separation of network traffic may prevent excessive rates of Ethernet packet collisions in a larger network. The subnets may be arranged logically in a hierarchical architecture, partitioning the organization's network address space into a tree-like routing structure. Routers are used to interchange traffic between subnetworks; they constitute logical or physical borders between the subnets, and manage traffic between subnets based on the high-order bit sequence (routing prefix) of host addresses.
A routing prefix is the sequence of leading (most-significant) bits of an IP address that precede the portion of the address used as host identifier. Routing prefixes are expressed in CIDR notation. A routing prefix in CIDR notation is the first address of a network followed by the bit-length of the prefix, separated by a slash (/) character. For example, 192.168.1.0/24 is the prefix of the IPv4 network starting at the given address, having 24 bits allocated for the network number, and the rest (8 bits) reserved for host addressing. The IPv6 address specification 2001:db8::/32 is a large network for 296 hosts, having a 32-bit routing prefix.
In IPv4 networks, the routing prefix is traditionally expressed as a subnet mask, which is the prefix bit mask expressed in quad-dotted decimal representation. For example, 255.255.255.0 is the subnet mask for the 192.168.1.0/24 prefix.
All hosts within a subnet can be reached in one routing hop, implying that all hosts in a subnet are connected to the same link.
A typical subnet is a physical network served by one router, for instance an Ethernet network, possibly consisting of one or several Ethernet segments or local area networks, interconnected by network switches and network bridges or a Virtual Local Area Network (VLAN). However, subnetting allows the network to be logically divided regardless of the physical layout of a network, since it is possible to divide a physical network into several subnets by configuring different host computers to use different routers.
While improving network performance, subnetting increases routing complexity, since each locally connected subnet must be represented by a separate entry in the routing tables of each connected router. However, by careful design of the network, routes to collections of more distant subnets within the branches of a tree-hierarchy can be aggregated by single routes. Existing subnetting functionality in routers made the introduction of Classless Inter-Domain Routing seamless.
Contents |
Computers and devices that are participating in a network such as the Internet each have a logical address. Usually this address is unique to each device and can either be configured dynamically from a network server or statically by an administrator. An address fulfills the functions of identifying the host and locating it on the network. It allows a device to communicate with other devices connected to the network. The most common network addressing architecture is Internet Protocol version 4 (IPv4), but its successor, IPv6 is in early deployment stages. An IPv4 address consists of 32 bits, for human readability written in a form consisting of four decimal octets separated by full stops (dots), called dot-decimal notation. An IPv6 address consists of 128 bits written in a hexadecimal notation and grouping 16 bits separated by colons.
In order to facilitate routing a data packet across multiple networks, the address is divided into two parts:
The network prefix may be written in a form identical to that of the address itself. In IPv4, this is called the subnet mask of the address. For example, a specification of the most-significant 18 bits of an address, 11111111.11111111.11000000.00000000
, is written as 255.255.192.0
.
The modern standard form of specification of the routing prefix counts the number of bits in the routing prefix and appends that number to the address with a slash (/) separator:
This latter notation is used preferentially in Classless Inter-Domain Routing and is called CIDR notation. In IPv6 this is the only acceptable form to denote routing prefixes.
The process of subnetting involves the separation of the network and subnet portion of an address from the host identifier. This is performed by a bitwise AND operation between the IP address and the subnet prefix or bit mask. The result yields the network address, and the remainder is the host identifier.
The following example is based on IPv4 networking. The operation may be visualized in a table using binary address formats.
Dot-decimal notation | Binary form | |
---|---|---|
IP address | 192.168.5.130 | 11000000.10101000.00000101.10000010 |
Subnet Mask | 255.255.255.0 | 11111111.11111111.11111111.00000000 |
Network Portion | 192.168.5.0 | 11000000.10101000.00000101.00000000 |
Host Portion | 0.0.0.130 | 00000000.00000000.00000000.10000010 |
In IPv4, subnet masks consist of 32 bits, usually a sequence of ones (1) followed by a block of 0s. The last block of zeros (0) designate that part as being the host identifier.
Subnetting is the process of designating bits from the host portion and grouping them with the network portion. This divides a network into smaller subnets. The following diagram modifies the example by moving two bits from the host portion to the subnet number to form a smaller subnet:
Dot-decimal notation | Binary form | |
---|---|---|
IP address | 192.168.5.130 | 11000000.10101000.00000101.10000010 |
Subnet Mask | 255.255.255.192 | 11111111.11111111.11111111.11000000 |
Network Portion | 192.168.5.128 | 11000000.10101000.00000101.10000000 |
Host Portion | 0.0.0.2 | 00000000.00000000.00000000.00000010 |
Internet Protocol version 4 uses specially designated address formats to facilitate recognition of special address functionality. The first and the last subnets obtained by subnetting have traditionally had a special designation and, early on, special usage implications.[3] In addition, IPv4 uses the all ones host address, i.e. the last address within a network, for broadcast transmission to all hosts on the link.
The first subnet obtained from subnetting has all bits in the subnet bit group set to zero (0). It is therefore called subnet zero.[4] The last subnet obtained from subnetting has all bits in the subnet bit group set to one (1). It is therefore called the all-ones subnet.[5]
The IETF discouraged the production use of these two subnets at one point due to possible confusion of having a network and subnet with the same address. According to RFC 950, "It is useful to preserve and extend the interpretation of these special (network and broadcast) addresses in subnetted networks. This means the values of all zeros and all ones in the subnet field should not be assigned to actual (physical) subnets."[6] The practice of avoiding subnet zero and the all-ones subnet eventually became obsolete with RFC 1878, published in 1995. It explicitly states: "This practice is obsolete! Modern software will be able to utilize all definable networks."[7]
The number of subnetworks available, and the number of possible hosts in a network may be readily calculated. In the example (above) two bits were borrowed to create subnetworks, thus creating 4 (22) possible subnets.
Network | Network (binary) | Broadcast address |
---|---|---|
192.168.5.0/26 | 11000000.10101000.00000101.00000000 | 192.168.5.63 |
192.168.5.64/26 | 11000000.10101000.00000101.01000000 | 192.168.5.127 |
192.168.5.128/26 | 11000000.10101000.00000101.10000000 | 192.168.5.191 |
192.168.5.192/26 | 11000000.10101000.00000101.11000000 | 192.168.5.255 |
The RFC 950 specification reserves the subnet values consisting of all zeros (see above) and all ones (broadcast), reducing the number of available subnets by two. However, due to the inefficiencies introduced by this convention it was abandoned for use on the public Internet, and is only relevant when dealing with legacy equipment that does not implement CIDR. The only reason not to use the all-zeroes subnet is that it is ambiguous when the prefix length is not available. All CIDR-compliant routing protocols transmit both length and suffix. RFC 1878 provides a subnetting table with examples.
The remaining bits after the subnet are used for addressing hosts within the subnet. In the above example the subnet mask consists of 26 bits, leaving 6 bits for the host identifier. This allows for 64 combinations (26), however the all zeros value and all ones value are reserved for the network ID and broadcast address respectively, leaving 62 addresses.
In general the number of available hosts on a subnet is 2n−2, where n is the number of bits used for the host portion of the address.
RFC 3021 specifies an exception to this rule when dealing with 31-bit subnet masks (i.e. 1-bit host identifiers). In such networks, usually point-to-point links, only two hosts (the end points) may be connected and a specification of network and broadcast addresses is not necessary.
A /24 network may be divided into the following subnets by increasing the subnet mask successively by one bit. This affects the total number of hosts that can be addressed in the /24 network (last column).
CIDR notation | Network mask | Available subnets | Available hosts per subnet | Total usable hosts |
---|---|---|---|---|
/24 | 255.255.255.0 | 1 | 254 | 254 |
/25 | 255.255.255.128 | 2 | 126 | 252 |
/26 | 255.255.255.192 | 4 | 62 | 248 |
/27 | 255.255.255.224 | 8 | 30 | 240 |
/28 | 255.255.255.240 | 16 | 14 | 224 |
/29 | 255.255.255.248 | 32 | 6 | 192 |
/30 | 255.255.255.252 | 64 | 2 | 128 |
/31 | 255.255.255.254 | 128 | 2 * | 256 |
*only applicable for point-to-point links
The design of the IPv6 address space differs significantly from IPv4. The primary reason for subnetting in IPv4 is to improve efficiency in the utilization of the relatively small address space available, particularly to enterprises. No such limitations exist in IPv6, as the address space available even to end-users is large.
An IPv6 subnet always has 64 bits in its host portion. It therefore has a /64 routing prefix (the 64 most-significant bits). Although it is technically possible to use smaller subnets, they are impractical for local area networks because stateless address auto configuration of network interfaces (RFC 4862) requires a /64 address. The Internet Engineering Task Force recommends to use /64 subnets even for point-to-point links, which consisting of only the two end hosts.
The recommended allocation for an IPv6 customer site is an address space of 80 address bits (prefix /48).[8] This provides 65536 subnets for a site. Despite this recommendation, other common allocations are /56 (72 bits) as well as /64 prefixes for a residential customer network.
IPv6 does not implement special address formats for broadcast traffic or network numbers, and thus all addresses in a subnet are valid host addresses.
Subnetting in IPv6 is based on the concepts of variable-length subnet masking (VLSM) and the Classless Inter-Domain Routing methodology. It is used to route traffic between the global allocation spaces and within customer network between subnets and the larger Internet.